﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Portal
{
    public static class MyLinqExtensions
    {
        public static bool IsLike(this string source, string pattern)
        {
            pattern = "%" + pattern + "%";
            pattern = Regex.Escape(pattern);
            pattern = pattern.Replace("%", ".*?").Replace("_", ".");
            pattern = pattern.Replace(@"\[", "[").Replace(@"\]", "]").Replace(@"\^", "^");
            return Regex.IsMatch(source, pattern);
        }


    }
}
